﻿<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<link rel="STYLESHEET" type="text/css" id="SkinStyleSheet">
<title></title>
<style type="text/css">
td{
	padding:5px
}
</style>
<script language="javascript" type="text/javascript" src="../script/windialog.js"></script>
<script language="javascript" type="text/javascript">

window.onload=function()
{
	document.title=EditorWindow.lang_contentformat;
	EditorWindow.renderWindowAsIE(window);
	var sel0=new EditorWindow._HTMLselect("selunitlineHeight",document);
	var sel1=new EditorWindow._HTMLselect("selunitpMarginBottom",document);
	var Options = new Array(
		new Array("%", "%"), 
		new Array("px", "px"),
		new Array("em", "em")
	);
	sel0.addOptions(Options);
	
	Options = new Array(
		new Array("px", "px"),
		new Array("em", "em")
	);
	
	Options1 = new Array(
		new Array("em", "em"),
		new Array("px", "px")		
	);

	sel1.addOptions(Options);
	sel1=new EditorWindow._HTMLselect("selunitpMarginTop",document);
	sel1.addOptions(Options);
	
	sel1=new EditorWindow._HTMLselect("selunittextindent",document);
	sel1.addOptions(Options1);
	
	sel0=null;
	sel1=null;

	var i,elems;
	if(XEditor.selectstatus==2)
	{
		//仅作用于选中文本区域
		elems=document.getElementsByTagName("div");
		for (i=0;i<elems.length;i++)
		{
			if(elems[i].className=="actonall")
			{
				
				elems[i].style.color="gray";
			}
		}
		elems=null;
		document.getElementById("checkbox_br2p").disabled=true;
	}
	
	AutoResizeDialogWindow();
}

function __btnOk_onclick()
{
	__contentformat();
	window.close();
}
function __btnUse_onclick()
{
	__contentformat();
}


function __btnCancel_onclick()
{
	window.close();
}

function __contentformat()
{
	var d0,d1,d2,d3,d4,__innerHTML;
	var __lineHeight=document.getElementById("input_lineHeight").value;
	var __lineHeightUnit=document.getElementById("selunitlineHeight").value;
	
	var __textindent=document.getElementById("input_textindent").value;
	
	var __pmarginTop=document.getElementById("input_marginTop").value;
	var __pmarginUnitTop=document.getElementById("selunitpMarginTop").value;

	
	var __pmarginBottom=document.getElementById("input_marginBottom").value;
	var __pmarginUnitBottom=document.getElementById("selunitpMarginBottom").value;

	d0=document.getElementById("checkbox_br2p").checked;
	d2=document.getElementById("checkbox_align_justify").checked;
	d3=document.getElementById("r3").checked;
	d4=document.getElementById("checkbox_hiddenhtmlobjects").checked;

	if (d0)
	{
		__innerHTML=XEditor.document.body.innerHTML;
		__innerHTML=__innerHTML.replace(new RegExp("\<BR\>", "gi"), "\<P\>");
		XEditor.document.body.innerHTML=__innerHTML;
		__innerHTML=XEditor.document.body.innerHTML;
		__innerHTML=__innerHTML.replace(new RegExp("\<P\>", "gi"), "\<\/P><P\>");
		XEditor.document.body.innerHTML=__innerHTML;

	}
	//没有选中任何内容
	var i,elems;

	if (d3)
	{
		if (XEditor.selectstatus==0 || XEditor.selectstatus==1 || XEditor.selectstatus==3)
		{
			//作用于整个文本
			elems=XEditor.document.links;
		}
		else if(XEditor.selectstatus==2)
		{
			//仅作用于选中文本区域
			elems=EditorWindow.__getElementsInRangeByTagName("a");
			
		}

		for (i=0;i<elems.length;i++)
		{
			if(!(elems[i].href.toString().indexOf(location.hostname)>0))
			{
				
				elems[i].removeNode();
			}
		}
		elems=null;
	}
	
	if(d4)
	{
		
		elems=XEditor.document.all;

		for (i=0;i<elems.length;i++)
		{
			if(elems[i].style.display=="none" || elems[i].style.visibility=="hidden")
			{
				elems[i].innerHTML="";
				elems[i].removeNode();
			}
		}
		elems=null;
	}
		
		
	if (XEditor.selectstatus==0 || XEditor.selectstatus==3)
	{
		//作用于整个文本
		elems=XEditor.document.getElementsByTagName("p");
	}
	else if(XEditor.selectstatus==2)
	{
		//仅作用于选中文本区域
		XEditor.document.execCommand("FormatBlock",null,"<P>");
		elems=EditorWindow.__getElementsInRangeByTagName("p");
	}

		
	for (i=0;i<elems.length;i++)
	{
		if (__textindent)
		{
			elems[i].style.textIndent=__textindent+document.getElementById("selunittextindent").value;		//首行缩进
		}
		if(d2)
		{
			if (elems[i].style.textAlign=="left" || elems[i].style.textAlign=="")
			{
				//设置2端对齐
				elems[i].style.textAlign="justify";
				elems[i].style.textJustify="inter-ideograph";
			}
		}
		if(__lineHeight)
		{
			elems[i].style.lineHeight=__lineHeight+__lineHeightUnit;		//行距
		}
		if(__pmarginBottom)
		{
			elems[i].style.marginBottom=__pmarginBottom+__pmarginUnitBottom;
		}

		if(__pmarginTop)
		{
			elems[i].style.marginTop=__pmarginTop+__pmarginUnitTop;
		}

	}
	elems=null;

	alert(EditorWindow.lang_finished);
}
</script>
</head>
<body class="dialog">
<script language="javascript" type="text/javascript">dialogTitle("lang_contentformat");</script>

<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
    	<input type="checkbox" id="r3">
    	<script language="javascript">
    		document.write(EditorWindow.lang_removelinksnotinthisdomain);
    	</script>
    </td>
    <td>
    	<script language="javascript">
    		document.write(EditorWindow.lang_setparagraph_textindent);
    	</script>
    </td>
    <td>
		<input type="text" id="input_textindent" value="" style="width: 45px" datatype="number">
		<select id="selunittextindent"></select>
    </td>
  </tr>
  <tr>
    <td>
    	<input type="checkbox" id="checkbox_align_justify">
    	<script language="javascript">
    		document.write(EditorWindow.lang_align_justify);
    	</script>
    </td>
    <td>
        <script language="javascript">
    		document.write(EditorWindow.lang_css_lineheight);
    	</script>
    </td>
    <td>
    	<input type="text" id="input_lineHeight" value="" style="width: 45px" datatype="number">
    	<select id="selunitlineHeight"></select>
    </td>
  </tr>
  <tr>
    <td>
    	<div class="actonall">
    	<input type="checkbox" id="checkbox_br2p">
    	<script language="javascript">
    		document.write(EditorWindow.lang_br2p);
    	</script>
    	</div>
	</td>
    <td>
    	<script language="javascript">
    		document.write(EditorWindow.lang_paragraphmargintop);
    	</script>
	</td>
    <td>
    	<input type="text" id="input_marginTop" value="" style="width: 45px" datatype="number">
    	<select id="selunitpMarginTop"></select>
    </td>
  </tr>
  <tr>
    <td>
    	<input type="checkbox" id="checkbox_hiddenhtmlobjects">
    	<script language="javascript">
    		document.write(EditorWindow.lang_removehiddenobject);
    	</script>
    </td>
    <td>
    	<script language="javascript">
    		document.write(EditorWindow.lang_paragraphmarginbottom);
    	</script>
	</td>
    <td>
    	<input type="text" id="input_marginBottom" value="" style="width: 45px" datatype="number">
    	<select id="selunitpMarginBottom" name="D1"></select>
    </td>
  </tr>
  <tr>
    <td>
    	&nbsp;</td>
    <td>
    		&nbsp;</td>
    <td>
    	&nbsp;</td>
  </tr>
</table>

<div class="buttons">
	<hr size="1" color="#B3AC9D">
	<script language="javascript" type="text/javascript">
		PrintButtons();
	</script>
</div>

</body>

</html>
